package display;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JList;

import model.Tour;
import java.awt.BorderLayout;
import javax.swing.SwingConstants;

import datencontext.Datencontext;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;

public class StreetViewDisplay extends JPanel {

	/**
	 * Create the panel.
	 */
	private JFrame jframe;
	
	public StreetViewDisplay(final JFrame jframe, final Tour tour) {
		this.jframe = jframe;
		setLayout(new BorderLayout(0, 0));
		
		JLabel lblNewLabel = new JLabel(Datencontext.HoleStrassenauswahlText(tour.getBenutzer(), tour.getTourName()));
		add(lblNewLabel,BorderLayout.NORTH);
		
		
		DefaultListModel<String> defaultlistmodel = new DefaultListModel<String>();
		for(int i = 0; i < tour.getArraylistStrasse().size();i++)
		{
			defaultlistmodel.addElement(tour.getArraylistStrasse().get(i).getStrassennamen());
		}
		JList<String> list = new JList<String>(defaultlistmodel);
		list.addListSelectionListener(new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent arg0) {
				jframe.getContentPane().removeAll();
				jframe.getContentPane().add(new HouseNumberChooserDisplay(), BorderLayout.CENTER);
				jframe.getContentPane().validate();
			}
		});
		add(list,BorderLayout.CENTER);
		
		JLabel lblNewLabel_1 = new JLabel("Bitte w\u00E4hlen Sie die Startstrasse aus.");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setLabelFor(list);
		add(lblNewLabel_1,BorderLayout.SOUTH);
	}
}
